﻿set(3RD_COPY_DLL_DIR ${CMAKE_BINARY_DIR}/Src/Core/Debug)
# message(STATUS "3RD_COPY_DLL_DIR: ${3RD_COPY_DLL_DIR}")

# -------------------- OCCT配置 --------------------
# find_package(OpenCASCADE REQUIRED)
# include_directories(${OpenCASCADE_INCLUDE_DIR})
# link_directories(${OpenCASCADE_LIBRARY_DIR})
# link_libraries(${OpenCASCADE_LIBRARIES_dir})
# message(STATUS "OpenCASCADE_INCLUDE_DIR: ${OpenCASCADE_INCLUDE_DIR}")
# message(STATUS "OpenCASCADE_LIBRARY_DIR: ${OpenCASCADE_LIBRARY_DIR}")
# message(STATUS "OpenCASCADE_LIBRARIES_dir: ${OpenCASCADE_LIBRARIES_dir}")

set(OCCT_ROOT ${CMAKE_SOURCE_DIR}/3rd/OCCT-7.5.0)
set(OpenCASCADE_INCLUDE_DIR ${OCCT_ROOT}/inc)
set(OpenCASCADE_DLL_DIR ${OCCT_ROOT}/win64/vc14/bin)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(OpenCASCADE_LIBRARY_DIR ${OCCT_ROOT}/win64/vc14/libd)
else()
    set(OpenCASCADE_LIBRARY_DIR ${OCCT_ROOT}/win64/vc14/lib)
endif()

# 打印路径信息
# message(STATUS "OpenCASCADE_INCLUDE_DIR: ${OpenCASCADE_INCLUDE_DIR}")
# message(STATUS "OpenCASCADE_LIBRARY_DIR: ${OpenCASCADE_LIBRARY_DIR}")
# message(STATUS "OpenCASCADE_DLL_DIR: ${OpenCASCADE_DLL_DIR}")
# message(STATUS "3RD_COPY_DLL_DIR: ${3RD_COPY_DLL_DIR}")

# 查找OCCT库
find_library(TKernel TKernel PATHS ${OpenCASCADE_LIBRARY_DIR} REQUIRED)
find_library(TKBRep TKBRep PATHS ${OpenCASCADE_LIBRARY_DIR} REQUIRED)
find_library(TKMath TKMath PATHS ${OpenCASCADE_LIBRARY_DIR} REQUIRED)
find_library(TKG3d TKG3d PATHS ${OpenCASCADE_LIBRARY_DIR} REQUIRED)
find_library(TKTopAlgo TKTopAlgo PATHS ${OpenCASCADE_LIBRARY_DIR} REQUIRED)
find_library(TKBO TKBO PATHS ${OpenCASCADE_LIBRARY_DIR} REQUIRED)
find_library(TKPrim TKPrim PATHS ${OpenCASCADE_LIBRARY_DIR} REQUIRED)
find_library(TKSTEP TKSTEP PATHS ${OpenCASCADE_LIBRARY_DIR} REQUIRED)
find_library(TKService TKService PATHS ${OpenCASCADE_LIBRARY_DIR} REQUIRED)
find_library(TKV3d TKV3d PATHS ${OpenCASCADE_LIBRARY_DIR} REQUIRED)
find_library(TKIVtk TKIVtk PATHS ${OpenCASCADE_LIBRARY_DIR} REQUIRED)
find_library(TKMeshVS TKMeshVS PATHS ${OpenCASCADE_LIBRARY_DIR} REQUIRED)

# 提升变量到父作用域
set(OpenCASCADE_INCLUDE_DIR ${OpenCASCADE_INCLUDE_DIR} PARENT_SCOPE)
set(OCCT_LIBRARIES 
        ${TKernel}
        ${TKBRep}
        ${TKMath}
        ${TKG3d}
        ${TKTopAlgo}
        ${TKBO}
        ${TKPrim}
        ${TKSTEP}
        ${TKService}
        ${TKV3d}
        ${TKIVtk}
        ${TKMeshVS}
        PARENT_SCOPE)

# 将dll文件复制到运行目录
file(COPY ${OpenCASCADE_DLL_DIR}/ DESTINATION ${3RD_COPY_DLL_DIR})


# -------------------- VTK配置 --------------------
set(VTK_ROOT ${CMAKE_SOURCE_DIR}/3rd/VTK-9.0.1)
set(VTK_INCLUDE_DIR ${VTK_ROOT}/include/vtk-9.0)
set(VTK_LIBRARY_DIR ${VTK_ROOT}/lib)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(VTK_DLL_DIR ${VTK_ROOT}/bin/debug)
else()
    set(VTK_DLL_DIR ${VTK_ROOT}/bin/release)
endif()

# 打印路径信息
# message(STATUS "VTK_INCLUDE_DIR: ${VTK_INCLUDE_DIR}")
# message(STATUS "VTK_LIBRARY_DIR: ${VTK_LIBRARY_DIR}")
# message(STATUS "VTK_DLL_DIR: ${VTK_DLL_DIR}")

# 查找VTK库
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    find_library(vtkCommonColor-9.0 vtkCommonColor-9.0d PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkCommonCore-9.0 vtkCommonCore-9.0d  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkCommonExecutionModel-9.0 vtkCommonExecutionModel-9.0d  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkCommonDataModel-9.0 vtkCommonDataModel-9.0d PATHS ${VTK_LIBRARY_DIR} REQUIRED)    
    find_library(vtkFiltersSources-9.0 vtkFiltersSources-9.0d  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkInteractionStyle-9.0 vtkInteractionStyle-9.0d  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkInteractionWidgets-9.0 vtkInteractionWidgets-9.0d  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkRenderingContextOpenGL2-9.0 vtkRenderingContextOpenGL2-9.0d  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkRenderingCore-9.0 vtkRenderingCore-9.0d  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkRenderingFreeType-9.0 vtkRenderingFreeType-9.0d  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkRenderingGL2PSOpenGL2-9.0 vtkRenderingGL2PSOpenGL2-9.0d  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkRenderingOpenGL2-9.0 vtkRenderingOpenGL2-9.0d  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkRenderingContext2D-9.0 vtkRenderingContext2D-9.0d  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkfreetype-9.0 vtkfreetype-9.0d  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
else()
    find_library(vtkCommonColor-9.0 vtkCommonColor-9.0 PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkCommonCore-9.0 vtkCommonCore-9.0  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkCommonExecutionModel-9.0 vtkCommonExecutionModel-9.0  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkCommonDataModel-9.0 vtkCommonDataModel-9.0 PATHS ${VTK_LIBRARY_DIR} REQUIRED)    
    find_library(vtkFiltersSources-9.0 vtkFiltersSources-9.0  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkInteractionStyle-9.0 vtkInteractionStyle-9.0  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkInteractionWidgets-9.0 vtkInteractionWidgets-9.0  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkRenderingContextOpenGL2-9.0 vtkRenderingContextOpenGL2-9.0  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkRenderingCore-9.0 vtkRenderingCore-9.0  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkRenderingFreeType-9.0 vtkRenderingFreeType-9.0  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkRenderingGL2PSOpenGL2-9.0 vtkRenderingGL2PSOpenGL2-9.0  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkRenderingOpenGL2-9.0 vtkRenderingOpenGL2-9.0  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkRenderingContext2D-9.0 vtkRenderingContext2D-9.0  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
    find_library(vtkfreetype-9.0 vtkfreetype-9.0  PATHS ${VTK_LIBRARY_DIR} REQUIRED)
endif()

# 提升变量到父作用域
set(VTK_INCLUDE_DIR ${VTK_INCLUDE_DIR} PARENT_SCOPE)
set(VTK_LIBRARIES 
                ${vtkCommonColor-9.0}
                ${vtkCommonCore-9.0}
                ${vtkCommonExecutionModel-9.0}
                ${vtkCommonDataModel-9.0}
                ${vtkFiltersSources-9.0}
                ${vtkInteractionStyle-9.0}
                ${vtkInteractionWidgets-9.0}
                ${vtkRenderingContextOpenGL2-9.0}
                ${vtkRenderingCore-9.0}
                ${vtkRenderingFreeType-9.0}
                ${vtkRenderingGL2PSOpenGL2-9.0}
                ${vtkRenderingOpenGL2-9.0}
                ${vtkRenderingContext2D-9.0}
                ${vtkfreetype-9.0}
                PARENT_SCOPE)

# 将dll文件复制到运行目录
set(FREETYPE_DLL_DIR ${CMAKE_SOURCE_DIR}/3rd/freetype-2.5.5-vc14-64/bin)
file(COPY ${FREETYPE_DLL_DIR}/ DESTINATION ${3RD_COPY_DLL_DIR})

# -------------------- FreeType配置 ----------
# 将dll文件复制到运行目录
file(COPY ${VTK_DLL_DIR}/ DESTINATION ${3RD_COPY_DLL_DIR})

# -------------------- 其他第三方库 --------------------
add_subdirectory(tinyxml2)